package mx.netbrain.dao.impl;

import mx.netbrain.dao.SignatureDao;
import mx.netbrain.model.Signature;
import mx.netbrain.util.HibernateUtil;

import org.apache.log4j.Logger;
import org.hibernate.Session;

public class SignatureDaoImpl implements SignatureDao {

	private static final Logger logger = Logger
			.getLogger(SignatureDaoImpl.class);

	@Override
	public Signature findById() {
		Session session = HibernateUtil.getSessionFactory().openSession();
		return (Signature) session.load(Signature.class, 1);
	}

	@Override
	public void update(Signature signature) {
		Session session = HibernateUtil.getSessionFactory().openSession();
		try {
			session.beginTransaction();
			session.merge(signature);
			session.beginTransaction().commit();
		} catch (Exception e) {
			logger.error("Update: " + e.getMessage());
			session.beginTransaction().rollback();
		}
	}

}
